package com.code.lightning.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author LGX_TvT
 * @date 2021-01-14 21:55
 */
public class DateUtil {

    public final static String format1 = "yyyyMMdd";
    public final static String format2 = "yyyy-MM-dd";
    public final static String format3 = "yyyy年MM月dd日";
    public final static String format4 = "yyyy-MM-dd HH:mm:ss";
    public final static String format5 = "yyyy年MM月dd日 HH时mm分ss秒";

    /**
     * 格式化
     * @param date 日期
     * @param pattern 格式化格式
     * @return 字符串
     */
    public static String format(Date date, String pattern) {
        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
        return dateFormat.format(date);
    }
}
